//
//  ViewController.m
//  CollTest
//
//  Created by codew on 8/31/21.
//

#import "ViewController.h"
#import "CPSCVideoShortVideoViewController.h"
#import "CPSCVideoLectureViewController.h"
#import "CPSCHomeToolsAllViewController.h"
#import "XBTextLoopView.h"
#import "CPSCHomeWaterfallViewController.h"
#import "CPSCTextLoopView.h"
#import "CPSCTBTestViewController.h"

#import "SDCycleScrollView.h"
#import "CustomPageControl.h"
#import "DGGCCycleAdView.h"

#import "CPSCCouponCommonVC.h"
#import "GradientLabel.h"

//#import <PLPlayerKit/PLPlayerKit.h>

@interface ViewController ()

//@property(nonatomic, strong) DGGCCycleAdView *advView;
@property (nonatomic, strong) UILabel * lblTest;

@end



@implementation ViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    NSString *title = @"nimadea800块";
    
    NSRange range1 = [title rangeOfString:@"800块"];
    
    if (range1.length != 0) {
        
    }
    NSLog(@"%@", NSStringFromRange(range1));
    
//    [PPNetworkCache ];;
//    NSDictionary*dict=@{@"k1":@"v1",@"k2":@"v2"};
//    for (NSString * key in dict.allKeys) {
//
//        NSString *value = dict[key];
//        NSLog(@"%@", value);
//    }
    
    
//    UIView * ttView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 400, 100)];
//    [self.view addSubview:ttView];
//
//
//    GradientLabel *label = [[GradientLabel alloc] init];
//    label.textAlignment = NSTextAlignmentCenter;
//    label.frame = ttView.bounds;
//    label.backgroundColor = [UIColor clearColor];
//    label.font = [UIFont systemFontOfSize:40 weight:1];
//    label.numberOfLines = 0;
//    label.text = @"会员卡";
//    [ttView addSubview:label];
//
//    [label mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.left.right.bottom.mas_equalTo(0);
//    }];
//
//
////    [label setGradientLabelColors:@[(id)[UIColor redColor].CGColor,
////                                    (id)[UIColor yellowColor].CGColor,
////                                    (id)[UIColor blackColor].CGColor]
////     ];
//    [label setGradientLabelColors:@[(id)[UIColor colorWithHexString:@"#786041"].CGColor,
//                                    (id)[UIColor colorWithHexString:@"#2C2626"].CGColor,
//                                    (id)[UIColor blackColor].CGColor]
//     ];
//    [label setGradientLabelColors:@[
//        (id)[UIColor colorWithHexString:@"#2C2626"].CGColor,
//        (id)[UIColor colorWithHexString:@"#786041"].CGColor]
//     ];
    
    
//    // #786041-#2C2626
//    CAGradientLayer *layer = [[CAGradientLayer alloc] init];
//    layer.colors = @[(id)[UIColor colorWithHexString:@"#786041"].CGColor, (id)[UIColor colorWithHexString:@"#2C2626"].CGColor];
//    layer.startPoint = CGPointMake(0, 1);
//    layer.endPoint = CGPointMake(1, 1);
//    layer.frame = label.bounds;
//    layer.mask = label.layer; //把文字作为渐变图层的遮罩
//    [ttView.layer addSublayer:layer];
//    layer.mask = label.layer;
//    label.frame = layer.bounds;
//
////    [self test3];
    
//    [self addGradientRampWithColors:@[(id)[UIColor colorWithHexString:@"#786041"].CGColor, (id)[UIColor colorWithHexString:@"#2C2626"].CGColor] text:@"会员卡"];

}
//
//- (void)addGradientRampWithColors:(NSArray *)colors text:(NSString *)text {
// //label在父视图上的（x，y）的值不是中心点
// CGPoint point = CGPointMake(30, 500);
// UILabel *label = [[UILabel alloc]init];
// label.text = text;
// label.font = [UIFont systemFontOfSize:80 weight:1];
// // label.textAlignment = NSTextAlignmentCenter;
// [label sizeToFit];
// //label的中心和想象的一样啦！！
// label.center = CGPointMake(point.x + CGRectGetWidth(label.bounds)/2, point.y - CGRectGetHeight(label.bounds)/2);
// [self.view addSubview:label];
//
// //在后面添加渐变图层
// CAGradientLayer *gradientLayer = [CAGradientLayer layer];
// gradientLayer.frame = label.frame;
// gradientLayer.colors = colors;
// //渐变的方向（0，0） （0，1） （1，0）（1，1）为四个顶点方向
// //(I.e. [0,0] is the bottom-left
// // corner of the layer, [1,1] is the top-right corner.) The default values
// // are [.5,0] and [.5,1]
// gradientLayer.startPoint = CGPointMake(0, 1);
// gradientLayer.endPoint = CGPointMake(1, 1);
// [self.view.layer addSublayer:gradientLayer];
// gradientLayer.mask = label.layer;
// label.frame = gradientLayer.bounds;
//}




- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
    
    
//    CPSCTBTestViewController * vc = [[CPSCTBTestViewController alloc] init];
//    [self presentViewController:vc animated:NO completion:nil];
    
//    CPSCHomeToolsAllViewController * vc = [[CPSCHomeToolsAllViewController alloc] init];
//    [self presentViewController:vc animated:NO completion:nil];
    
    
//    CPSCHomeWaterfallViewController * vc = [[CPSCHomeWaterfallViewController alloc] init];
//    UINavigationController * nav = [[UINavigationController alloc] initWithRootViewController:vc];
//    [self presentViewController:vc animated:NO completion:nil];

   
    
    
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    CPSCCouponCommonVC * vc = [[CPSCCouponCommonVC alloc] init];
    UINavigationController * nav = [[UINavigationController alloc] initWithRootViewController:vc];
    [self presentViewController:nav animated:NO completion:nil];
    
//    CPSCHomeWaterfallViewController * vc = [[CPSCHomeWaterfallViewController alloc] init];
//    [self presentViewController:vc animated:NO completion:nil];
    
    
//    CPSCHomeToolsAllViewController * vc = [[CPSCHomeToolsAllViewController alloc] init];
//    [self presentViewController:vc animated:NO completion:nil];
    
    
//    CPSCTBTestViewController * vc = [[CPSCTBTestViewController alloc] init];
//    [self presentViewController:vc animated:NO completion:nil];
}


/**
 轮播图
 */
- (void)test4
{
    
    UIView * view = [[UIView alloc] initWithFrame:CGRectMake(20, 66, 300, 200)];
    view.backgroundColor = [UIColor yellowColor];
    view.clipsToBounds = YES;

//    // 网络加载图片的轮播器
//
//
//    [view addSubview:self.advView];
//    [self.advView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.left.right.bottom.mas_equalTo(0);
//    }];
//
////    self.advView.frame = view.bounds;
//    NSArray * arr = @[
//
//        @"https://t7.baidu.com/it/u=4198287529,2774471735&fm=193&f=GIF",
//        @"https://t7.baidu.com/it/u=1956604245,3662848045&fm=193&f=GIF",
//        @"https://t7.baidu.com/it/u=2529476510,3041785782&fm=193&f=GIF"
//    ];
//    [self.advView configCellWithAdsArr:arr
//                              duration:2
//                     isShowPageControl:YES
//                              adsClick:^(NSInteger index) {
//
//
//    } scrollBlock:^(NSInteger index) {
//    }];
//
//
//
//
//    [self.view addSubview:view];


}




- (void)test3
{
    
    NSArray *dataArray = @[
        @"我是跑马灯😆1",
        @"我是跑马灯😆2",
        @"我是跑马灯😆3",
        @"我是跑马灯😆4",
        @"我是跑马灯😆5",
        @"我是跑马灯😆6"
    ];
    
    
    NSMutableArray * arrayM = [NSMutableArray array];
    for (int i = 0; i < 4; i++) {
        
        [arrayM addObject:dataArray[i]];
    }
    
    NSLog(@"");
    
    
//
    CPSCTextLoopView * loopView = [[CPSCTextLoopView alloc] init];
//
    [self.view addSubview:loopView];
    loopView.backgroundColor = kCPSCRandomColor;
    CGFloat rowHeight = 60;
    [loopView updateViewWithDataSource:dataArray];
    loopView.interval = 3;
    loopView.rowHeight = rowHeight;
    [loopView mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.left.mas_equalTo(66);
        make.right.mas_equalTo(-30);
        make.height.mas_equalTo(rowHeight);
    }];
//
}

//- (DGGCCycleAdView *)advView {
//    if (!_advView) {
//        _advView = [[DGGCCycleAdView alloc] init];
//        _advView.layer.masksToBounds = YES;
////        [_advView addDarkMaskWithAlpha:0.16f];
//        _advView.hidden = NO;
////        _advView.cycleView.placeholderImage = @"";
//
//    }
//    return _advView;
//}
@end
